package com.cachopoid.utils;

import java.util.ArrayList;

import android.content.Context;
import android.provider.Settings;
import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cachopoid.R;
import com.cachopoid.vo.CachopoVO;
import com.cachopoid.vo.ComentarioVO;

public class ListaComentariosBaseAdapter extends BaseAdapter {
	 
	private static ArrayList<ComentarioVO> comentarioArrayList;
	private static ArrayList<CachopoVO> cachopoArrayList;
	private LayoutInflater l_Inflater;
	
	 
	public ListaComentariosBaseAdapter(Context context, ArrayList<ComentarioVO> comentarios) {
		comentarioArrayList = comentarios;
	  l_Inflater = LayoutInflater.from(context);
	}
	 
	public int getCount() {
	  return comentarioArrayList.size();
	}
	 
	public Object getItem(int position) {
	  return comentarioArrayList.get(position);
	}
	 
	public long getItemId(int position) {
	  return position;
	}
	 
	public View getView(int position, View convertView, ViewGroup parent) {
		  ViewHolder holder;
		  if (convertView == null) {
		   convertView = l_Inflater.inflate(R.layout.template_listacomentarios, null);
		   holder = new ViewHolder();
		   holder.txtComentarioDesc = (TextView) convertView.findViewById(R.id.comentario);
		   holder.txtCreadorComentario = (TextView) convertView.findViewById(R.id.creadorComentario);
		   holder.txtFechaComentario = (TextView) convertView.findViewById(R.id.fechaComentario);
		   convertView.setTag(holder);
		  } else {
		   holder = (ViewHolder) convertView.getTag();
		  }
		//  holder.txtCachopoComentado.setText(Utils.getCachopo2List(cachopoArrayList, comentarioArrayList.get(position).getIdCachopo()).getNombre());
		  holder.txtComentarioDesc.setText(comentarioArrayList.get(position).getComentario());
		  holder.txtCreadorComentario.setText(comentarioArrayList.get(position).getCreador_comentario());
		  String format = Settings.System.getString(parent.getContext().getContentResolver(), Settings.System.DATE_FORMAT);
		//  holder.txtFechaComentario.setText(DateFormat.format("dd/MM/yyyy", comentarioArrayList.get(position).getFecha_comentario())); 

	  return convertView;
	}
	 
	static class ViewHolder {
		 TextView txtComentarioDesc;
		 TextView txtCreadorComentario;
		 TextView txtFechaComentario;
	}
	 
	
}
